<template>
  <div class="">
    <!-- <h1>确认订单页面</h1> -->

    <van-contact-card
      v-if="adress"
      type="edit"
      :tel="adress.mobile"
      :name="adress.linkMan"
      @click="$router.push('/adresslist')"
    />
    <van-contact-card v-else type="add" @click="onAdd" />
    <!-- 显示默认地址 -->

    <van-card
      v-for="item in orderList"
      :key="item.id"
      :num="item.num"
      :price="item.price"
      :title="item.name"
      :thumb="item.img"
      :desc="item.properties"
    >
    </van-card>

    <!-- 选中的要结算的商品 -->
  </div>
</template>

<script>
import { ref, reactive, toRefs, computed } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
import { getDefaultAdress } from "@/utils/http/shopcar";
export default {
  setup(props, ctx) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const data = reactive({
      adress: "",
    });
    getDefaultAdress().then((res) => {
      console.log(res);
      if (res.code == 0) {
        data.adress = res.data;
      }
    });
    //获取默认的地址

    const orderList = computed(() => {
      return store.state.shopcar.filter((item) => {
        return item.status == true;
      });
    });
    //筛选状态是true的 选中的商品

    const onAdd = () => {
      router.push("/adressadd");
    };
    return { ...toRefs(data), orderList, onAdd };
  },
};
</script>

<style lang="scss"></style>
